import req from '@/utils/request'
import type { RoleListType } from './model/roleType'

enum Api {
  roleList = '/admin/acl/role',
  addRole = '/admin/acl/role/save',
  updataRole = '/admin/acl/role/update',
  removeRole = '/admin/acl/role/remove',
}

// 获取角色列表
export const getRoleListApi = (page: number, limit: number, name: string) => {
  return req.get<null, RoleListType>(`${Api.roleList}/${page}/${limit}`, {
    params: { roleName: name },
  })
}

// 添加角色
export const addRoleApi = (roleName: string) => {
  return req.post<null, null>(Api.addRole, { roleName })
}

// 修改角色
export const updataRoleApi = (roleName: string, id: string) => {
  return req.put<null, null>(Api.updataRole, { roleName, id })
}

// 删除角色
export const removeRole = (id: string) => {
  return req.delete<null, null>(`${Api.removeRole}/${id}`)
}
